import axios from '@/libs/api.request'
import HttpRequest from '@/libs/axios'
import config from '@/config'

const baseUrl1 = config.baseUrl.VUE_ORDER_URL + '/process-web'
const baseUrl2 = process.env.NODE_ENV === 'development' ? '/apiTest2' : 'http://39.100.121.98:8080'

/* 待办事项 processList */
export const processList = ({
  pageNum,
  pageSize,
  taskInfo
}) => {
  return new HttpRequest(baseUrl1).request({
    url: '/process/list',
    method: 'get',
    params: {
      pageNum,
      pageSize,
      taskInfo
    }
  })
}

/* 支付扩展保存 savePayParams */
export const savePayParams = (data) => {
  return new HttpRequest(baseUrl2).request({
    url: '/qjm-pay/pay/savePayParams',
    method: 'post',
    data: data
  })
}

/* 支付扩展查询 getPayParams */
export const getPayParams = (domainId) => {
  return new HttpRequest(baseUrl2).request({
    url: '/qjm-pay/pay/getPayParams',
    method: 'get',
    params: {
      domainId
    }
  })
}

/**
 * getDomainInfo（获取域信息（如果有多个域，默认返回查询得到的第一个））
 * @param {string | number} domainId 域ID主键
 */
export const queryDomainListByCookie = () => {
  return axios.request({
    url: 'gas/domain/domain/queryDomainListByCookie',
    data: {},
    method: 'post'
  })
}

/**
 * changeDomain
 */
export const changeDomain = ({ domainId }) => {
  return axios.request({
    url: 'gas/domain/domain/changeDomain',
    data: {
      domainId
    },
    method: 'post',
    headers: {
      'Content-type': 'application/json'
    }
  })
}

/**
 * listDomain（获取域列表(分页)）
 * @param {domainName: string} {}
 * @param {string} domainName 域名称
 * @param {number} pageNum 页号
 * @param {number} pageSize 每页数据条数
 */
export const listDomain = ({
  domainName,
  pageNum,
  pageSize
}) => {
  return axios.request({
    url: '/gas/domain/domain/list',
    data: {
      domainName,
      pageNum,
      pageSize
    },
    method: 'post'
  })
}
/**
 * 删除域
 * @param {number} domainId 域iD
 */
export const delDomain = (domainId) => {
  return axios.request({
    url: '/gas/domain/domain/delete',
    data: {
      domainId
    },
    method: 'post'
  })
}

/**
 * getMenuList（获取portal页面的模块数据(menulist菜单列表)）
 * @param {menuType: number} menuType  弹窗左侧主选项为1右侧子选项为2
 * @param {string} resIcon 图标url
 * @param {string} resName 名称标题
 * @param {number} parentId resourceId
 * @param {number} resourceId resourceId
 */
export const getProtalCinfigData = (pageSize) => {
  return axios.request({
    url: '/gas/domain/resource/getProtalCinfigData',
    data: JSON.stringify(pageSize),
    method: 'post'
  })
}
/**
 * getPortalMenuList（portal页menu列表）
 */
export const getPortalMenuList = () => {
  return axios.request({
    url: '/gas/domain/position/getPortalMenuList',
    data: {},
    method: 'post'
  })
}
/**
 * positionAdd（portal添加menu）
 */
export const positionAdd = (id) => {
  return axios.request({
    url: '/gas/domain/position/add',
    data: id,
    method: 'post'
  })
}
/**
 * positionDelete（portal删除menu）
 */
export const positionDelete = (id) => {
  return axios.request({
    url: '/gas/domain/position/delete',
    data: id,
    method: 'post'
  })
}

/**
 * bindDomainResource(域绑定资源接口
 * @param {object} resourceList
 */
export const bindDomainResource = ({
  domainId,
  resourceList
}) => {
  return axios.request({
    url: '/gas/domain/domain/bindResource',
    data: {
      domainId,
      resourceList
    },
    method: 'post'
  })
}
export const addDomain = ({
  cityId,
  domainName,
  logo,
  wechatId,
  wechatAppId,
  compId,
  resourceList,
  oriDomainId,
  otherDomainId,
  dubboGroup,
  rootName,
  loginPath,
  zookeeperUrl
}) => {
  return axios.request({
    url: '/gas/domain/domain/add',
    data: {
      cityId,
      domainName,
      logo,
      wechatId,
      wechatAppId,
      compId,
      resourceList,
      oriDomainId,
      otherDomainId,
      dubboGroup,
      rootName,
      loginPath,
      zookeeperUrl
    },
    method: 'post'
  })
}
/**
 * 编辑域
 * @param {*} param0
 */
export const updateDomain = ({
  cityId,
  otherDomainId,
  domainName,
  logo,
  wechatId,
  wechatAppId,
  compId,
  resourceList,
  dubboGroup,
  rootName,
  loginPath,
  zookeeperUrl,
  domainId
}) => {
  return axios.request({
    url: '/gas/domain/domain/update',
    data: {
      cityId,
      otherDomainId,
      domainName,
      logo,
      wechatId,
      wechatAppId,
      compId,
      resourceList,
      dubboGroup,
      rootName,
      loginPath,
      zookeeperUrl,
      domainId
    },
    method: 'post'
  })
}
/**
 * getDomainInfo（获取域信息（如果有多个域，默认返回查询得到的第一个））
 */
export const getDomainInfo = (domainId) => {
  return axios.request({
    url: '/gas/domain/domain/getDomainInfo',
    data: {
      domainId
    },
    method: 'post'
  })
}

/**
 * domainExtSave 域扩展编辑修改
 */
export const domainExtSave = (obj) => {
  return axios.request({
    url: '/gas/domain/domainExt/save',
    data: obj,
    method: 'post',
    headers: {
      'Content-type': 'application/json'
    }
  })
}
/**
 * getDomainExts 域扩展参数回显
 */
export const getDomainExts = (obj) => {
  return axios.request({
    url: '/gas/domain/domainExt/getDomainExts',
    data: obj,
    method: 'post'
  })
}

/**
 * domainExtSave 系统展示扩展添加
 */
export const domainDeployAdd = (obj) => {
  return axios.request({
    url: '/gas/domain/domainDeploy/add',
    data: obj,
    method: 'post',
    headers: {
      'Content-type': 'application/json'
    }
  })
}
/**
 * domainDeployUpdate 系统展示扩展修改
 */
export const domainDeployUpdate = (obj) => {
  return axios.request({
    url: '/gas/domain/domainDeploy/update',
    data: obj,
    method: 'post',
    headers: {
      'Content-type': 'application/json'
    }
  })
}
/**
 * domainDeployDelete 系统展示扩展删除
 */
export const domainDeployDelete = (obj) => {
  return axios.request({
    url: '/gas/domain/domainDeploy/delete',
    data: obj,
    method: 'post',
    headers: {
      'Content-type': 'application/json'
    }
  })
}
/**
 * getDeployByDomainId 系统展示扩展详情
 */
export const getDeployByDomainId = (obj) => {
  return axios.request({
    url: '/gas/domain/domainDeploy/getDeployByDomainId',
    data: obj,
    method: 'post',
    headers: {
      'Content-type': 'application/json'
    }
  })
}

/* domainAdminList 域管理员列表信息 */
export const domainAdminList = ({ pageNum,
  pageSize }) => {
  return axios.request({
    url: '/gas/domain/user/domainAdminList',
    data: {
      pageNum,
      pageSize
    },
    method: 'post'
  })
}
/* 解除管理员绑定 removeDomianAdmin */
export const removeDomianAdmin = (userId) => {
  return axios.request({
    url: '/gas/domain/user/removeDomianAdmin',
    data: {
      userId
    },
    method: 'post'
  })
}
/* 管理员绑定 addDomianAdmin */
export const addDomianAdmin = (userId) => {
  return axios.request({
    url: '/gas/domain/user/addDomianAdmin',
    data: {
      userId
    },
    method: 'post'
  })
}
